// constants/mockData.ts
import { KnowledgeBase, UserInfo, ShopData } from '../types';

// 分段数据类型
export interface Chunk {
  id: string;
  content: string;
  chunkIndex: number;
  wordCount: number;
}

// 扩展文档接口，包含分段数据
export interface DocumentWithChunks {
  id: string;
  name: string;
  summary: string; // 文件摘要
  chunk_num: number;
  upload_date: string;
  chunking_method: string;
  enable: boolean;
  parsing_status: 'Success' | 'Processing' | 'Failed';
  file_type: string;
  chunks: Chunk[]; // 关联的分段数据
}

export const mockKnowledgeBases: KnowledgeBase[] = [
  {
    id: 'kb_1',
    name: '客服知识库',
    description:
      '包含客服培训手册、常见问题解答和服务流程等相关文档资料，为客服团队提供标准化服务指导',
    doc_num: 156,
    avatar: '',
    nickname: '客服团队',
    permission: 'private',
    update_time: '2025/01/30 14:17:28',
    create_time: '2024-01-10T09:00:00Z',
  },
  {
    id: 'kb_2',
    name: '淘宝店铺运营手册',
    description: '淘宝店铺日常运营、推广策略、活动规划、数据分析等运营知识集合',
    doc_num: 89,
    avatar: '',
    nickname: '淘宝运营团队',
    permission: 'private',
    update_time: '2025/01/30 10:45:12',
    create_time: '2024-01-08T14:30:00Z',
    platform: 'taobao',
  },
  {
    id: 'kb_3',
    name: '天猫旗舰店管理',
    description:
      '天猫旗舰店品牌管理、商品上架、促销活动、客户关系维护等专业指导文档',
    doc_num: 234,
    avatar: '',
    nickname: '天猫团队',
    permission: 'private',
    update_time: '2025/01/29 16:22:45',
    create_time: '2024-01-15T11:20:00Z',
    platform: 'tmall',
  },
  {
    id: 'kb_4',
    name: '拼多多营销策略',
    description:
      '拼多多平台特色营销玩法、流量获取、转化优化、社群运营等实战经验分享',
    doc_num: 67,
    avatar: '',
    nickname: '拼多多运营',
    permission: 'private',
    update_time: '2025/01/28 09:15:33',
    create_time: '2024-01-20T08:45:00Z',
    platform: 'pdd',
  },
  {
    id: 'kb_5',
    name: '京东商城操作指南',
    description:
      '京东商城入驻流程、商品管理、物流配送、售后服务等全流程操作指南',
    doc_num: 178,
    avatar: '',
    nickname: '京东团队',
    permission: 'private',
    update_time: '2025/01/27 14:58:17',
    create_time: '2024-01-12T13:15:00Z',
    platform: 'jd',
  },
  {
    id: 'kb_6',
    name: '抖音直播带货宝典',
    description:
      '抖音直播间搭建、主播培训、商品选择、互动技巧、数据分析等直播带货全套方案',
    doc_num: 145,
    avatar: '',
    nickname: '抖音直播团队',
    permission: 'private',
    update_time: '2025/01/26 20:31:08',
    create_time: '2024-01-18T15:40:00Z',
    platform: 'douyin',
  },
  {
    id: 'kb_7',
    name: '小红书种草攻略',
    description:
      '小红书内容创作、KOL合作、社区运营、品牌推广等种草营销完整攻略',
    doc_num: 92,
    avatar: '',
    nickname: '小红书运营',
    permission: 'private',
    update_time: '2025/01/25 11:44:52',
    create_time: '2024-01-22T10:30:00Z',
    platform: 'xiaohongshu',
  },
  {
    id: 'kb_8',
    name: '产品技术文档',
    description:
      '产品架构设计、API接口文档、技术规范、开发指南等技术相关文档集合',
    doc_num: 312,
    avatar: '',
    nickname: '技术团队',
    permission: 'private',
    update_time: '2025/01/30 08:20:15',
    create_time: '2024-01-05T09:00:00Z',
  },
  {
    id: 'kb_9',
    name: '财务管理制度',
    description: '公司财务制度、报销流程、预算管理、税务处理等财务相关规范文档',
    doc_num: 78,
    avatar: '',
    nickname: '财务部',
    permission: 'private',
    update_time: '2025/01/24 15:33:27',
    create_time: '2024-01-08T14:20:00Z',
  },
  {
    id: 'kb_10',
    name: '天猫超市供应链',
    description:
      '天猫超市供应链管理、库存优化、配送策略、供应商合作等供应链知识库',
    doc_num: 203,
    avatar: '',
    nickname: '供应链团队',
    permission: 'private',
    update_time: '2025/01/23 12:18:44',
    create_time: '2024-01-14T16:25:00Z',
    platform: 'tmall',
  },
  {
    id: 'kb_11',
    name: '淘宝直通车投放',
    description:
      '淘宝直通车关键词优化、出价策略、创意制作、ROI提升等付费推广专业指导',
    doc_num: 134,
    avatar: '',
    nickname: '推广专员',
    permission: 'private',
    update_time: '2025/01/22 17:55:39',
    create_time: '2024-01-16T11:10:00Z',
    platform: 'taobao',
  },
  {
    id: 'kb_12',
    name: '人力资源管理',
    description: '员工招聘、绩效考核、薪酬体系、培训发展等人力资源管理完整体系',
    doc_num: 156,
    avatar: '',
    nickname: 'HR团队',
    permission: 'private',
    update_time: '2025/01/21 13:42:16',
    create_time: '2024-01-03T08:30:00Z',
  },
  {
    id: 'kb_13',
    name: '京东POP店铺运营',
    description:
      '京东POP商家入驻指南、店铺装修、商品推广、活动报名等运营实战手册',
    doc_num: 97,
    avatar: '',
    nickname: '京东POP团队',
    permission: 'private',
    update_time: '2025/01/20 09:27:58',
    create_time: '2024-01-19T14:50:00Z',
    platform: 'jd',
  },
  {
    id: 'kb_14',
    name: '抖音短视频创作',
    description:
      '抖音短视频脚本编写、拍摄技巧、剪辑方法、爆款打造等创作全流程指导',
    doc_num: 188,
    avatar: '',
    nickname: '抖音创作团队',
    permission: 'private',
    update_time: '2025/01/19 16:14:33',
    create_time: '2024-01-17T12:40:00Z',
    platform: 'douyin',
  },
  {
    id: 'kb_15',
    name: '拼多多商家工具',
    description:
      '拼多多商家后台操作、数据分析工具使用、推广工具应用等实用工具指南',
    doc_num: 73,
    avatar: '',
    nickname: '拼多多工具专家',
    permission: 'private',
    update_time: '2025/01/18 11:08:21',
    create_time: '2024-01-21T09:15:00Z',
    platform: 'pdd',
  },
];

// 新增一些平台相关的工具函数
export const getPlatformStats = () => {
  const platformCounts = mockKnowledgeBases.reduce(
    (acc, kb) => {
      if (kb.platform) {
        acc[kb.platform] = (acc[kb.platform] || 0) + 1;
      } else {
        acc['other'] = (acc['other'] || 0) + 1;
      }
      return acc;
    },
    {} as Record<string, number>,
  );

  return platformCounts;
};

export const getPlatformName = (platform?: string) => {
  const platformNames = {
    taobao: '淘宝',
    tmall: '天猫',
    pdd: '拼多多',
    jd: '京东',
    douyin: '抖音',
    xiaohongshu: '小红书',
  };

  return platform
    ? platformNames[platform as keyof typeof platformNames]
    : '通用';
};

export const mockUserInfo: UserInfo = {
  nickname: '用户',
  avatar: '',
};

export const groupedMockStores = [
  {
    platform: 'taobao',
    name: '淘宝',
    stores: [
      { id: 'store_1', name: '百货旗舰店' },
      { id: 'store_11', name: '淘宝男装店' },
    ],
  },
  {
    platform: 'tmall',
    name: '天猫',
    stores: [
      { id: 'store_2', name: '天猫数码店' },
      { id: 'store_12', name: '天猫家电专营店' },
    ],
  },
  {
    platform: 'jd',
    name: '京东',
    stores: [
      { id: 'store_3', name: '京东直营店' },
      { id: 'store_13', name: '京东图书馆' },
    ],
  },
  {
    platform: 'douyin',
    name: '抖音',
    stores: [
      { id: 'store_4', name: '抖音美妆店' },
    ],
  },
  {
    platform: 'pdd',
    name: '拼多多',
    stores: [
      { id: 'store_5', name: '拼多多母婴店' },
    ],
  },
  {
    platform: 'xiaohongshu',
    name: '小红书',
    stores: [
      { id: 'store_6', name: '小红书生活馆' },
    ],
  },
];

// 包含文件和分段关联的模拟数据
export const mockDocumentsWithChunks: DocumentWithChunks[] = [
  {
    id: 'doc_1',
    name: 'BISHENG达人1对1专家服务.docx',
    summary: 'BISHENG 达人 1 对 1 专家服务',
    chunk_num: 2,
    upload_date: '2025-04-16',
    chunking_method: '智能分块',
    enable: true,
    parsing_status: 'Success',
    file_type: 'DOCX',
    chunks: [
      {
        id: 'chunk_1_1',
        content:
          'BISHENG 达人 1 对 1 专家服务一直以来有许多朋友希望我们能提供更加专业，更精准的小规模企业咨询服务，近期，我们从 BISHENG 社区中陆续发掘出多名优秀...',
        chunkIndex: 1,
        wordCount: 970,
      },
      {
        id: 'chunk_1_2',
        content:
          '注意事项: BISHENG 达人开启半年算算官方人员，半年算官方仅提供位数对接，交易 三方倫帆与业务操作关系由，我们希望通过[BISHENG 达人]计划帮更多针区朋友把平...',
        chunkIndex: 2,
        wordCount: 140,
      },
    ],
  },
  {
    id: 'doc_2',
    name: '有意的内容.docx',
    summary: '有意的内容设计',
    chunk_num: 1,
    upload_date: '2025-04-16',
    chunking_method: '固定长度',
    enable: true,
    parsing_status: 'Success',
    file_type: 'DOCX',
    chunks: [
      {
        id: 'chunk_2_1',
        content: '有意的内容',
        chunkIndex: 1,
        wordCount: 5,
      },
    ],
  },
  {
    id: 'doc_3',
    name: '毕昇BISHENG品牌视觉素材.docx',
    summary: '毕昇 BISHENG 品牌视觉素材与企业...',
    chunk_num: 1,
    upload_date: '2025-04-16',
    chunking_method: '段落分块',
    enable: true,
    parsing_status: 'Success',
    file_type: 'DOCX',
    chunks: [
      {
        id: 'chunk_3_1',
        content:
          "毕昇 BISHENG 品牌视觉素材 LOGO轮!!0901 是 HENGHSHETT9.8 system a communication be couldn't and we wan't service We wign a hip...",
        chunkIndex: 1,
        wordCount: 258,
      },
    ],
  },
  {
    id: 'doc_4',
    name: 'Roadmap.docx',
    summary: '产品功能与版本规划路图',
    chunk_num: 6,
    upload_date: '2025-04-16',
    chunking_method: '智能分块',
    enable: true,
    parsing_status: 'Success',
    file_type: 'DOCX',
    chunks: [
      {
        id: 'chunk_4_1',
        content: 'Roadmap 是重采供：dataelem.feishu.cn 视频可能含有多项的价值',
        chunkIndex: 1,
        wordCount: 46,
      },
      {
        id: 'chunk_4_2',
        content:
          '|服务| 功能| 双蓝| 管理||-----|-----|-----|-----|| ☑ 0. 0.X版本|技能治理功能・本地过过管理・支特館豐预案同题 最答生成功能・私有化部署方案|・掌先缺...',
        chunkIndex: 2,
        wordCount: 805,
      },
      {
        id: 'chunk_4_3',
        content:
          '||用 API・支持特权能以链接 形式发布，可数快迅美施・文其数交流・年度 vlim 现升型型 坐理美图・自戶化课策略| 策略，工| ☑ 0. 2.X版本| 支特最出号杂较版・報告・新...',
        chunkIndex: 3,
        wordCount: 878,
      },
      {
        id: 'chunk_4_4',
        content:
          '|0.3.2|技能增加|・蜜型频效率評 意 用而・技能 BishengReagent(内部LLM技能 |・圣历毕昇 RAG 算法优化 策略|・策惑，工|0.3.3|・助手支技接口通用 与怎...',
        chunkIndex: 4,
        wordCount: 95,
      },
      {
        id: 'chunk_4_5',
        content:
          '||Diffusion/Flux 生成工具・自定义工具支持 custom 自定义验证码 新增模块 毕昇商城新增（限 DeepSeek 网页版）||1.1.2|口 工作流支持多段条窗...',
        chunkIndex: 5,
        wordCount: 467,
      },
      {
        id: 'chunk_4_6',
        content:
          '|口 语音交互| 口 语音交互| 口 语音交互| 链接| | 并开放|| |-----|-----|-----|-----|--| 近期 |企业 级板 业 状态 半昇 事对 企业 章求 晏域 体...',
        chunkIndex: 6,
        wordCount: 999,
      },
    ],
  },
  {
    id: 'doc_5',
    name: '毕昇合伙人计划.docx',
    summary: '毕昇合伙人计划数据简介',
    chunk_num: 1,
    upload_date: '2025-04-16',
    chunking_method: '智能分块',
    enable: true,
    parsing_status: 'Processing',
    file_type: 'DOCX',
    chunks: [
      {
        id: 'chunk_5_1',
        content:
          '毕昇合伙人计划 合伙人计划旨在我们自己式入 7 月与多客户作管理合伙作为毕昇的行为求来用的经营合作资和计帮为另作多伙伴带来的分值|价格-00}{下是合...',
        chunkIndex: 1,
        wordCount: 811,
      },
    ],
  },
];
